package com.juttec.freshbird.pet.luntantiezi;

import android.app.Activity;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.juttec.freshbird.pet.R;
import com.lidroid.xutils.ViewUtils;

/**
 * Created by Administrator on 2015/11/5.
 */
public class Jinghuatie extends BaseTiezi {

    private TextView tvHuitieNumber;
    private ListView lvZuixinfabu;

    public Jinghuatie(Activity activity) {
        super(activity);
    }

    @Override
    public View initView() {
        Log.e("pet","initview");
        View view = View.inflate(mActivity, R.layout.luntan_zuixinfabu, null);
        lvZuixinfabu = (ListView) view.findViewById(R.id.lv_luntan_zuixinfabu);
        tvHuitieNumber = (TextView) view.findViewById(R.id.tv_luntan_zuixinfabu_number);
        ViewUtils.inject(mActivity,view);
        return view;
    }

    @Override
    public void initData() {
        Log.e("pet","zhixingle");
        lvZuixinfabu.setAdapter(new ZuixinfabuLvAdapter());
        tvHuitieNumber.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(mActivity,"回帖子啦",Toast.LENGTH_SHORT).show();
            }
        });
    }

    class ZuixinfabuLvAdapter extends BaseAdapter{

        @Override
        public int getCount() {
            return 20;
        }

        @Override
        public Object getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder holder;
            if(convertView==null){
                convertView = View.inflate(mActivity, R.layout.luntan_tiezi_item, null);
                holder = new ViewHolder();
                holder.tvTiezi = (TextView) convertView.findViewById(R.id.luntan_tiezi);
                holder.tvHuifu = (TextView) convertView.findViewById(R.id.luntan_tiezi_huifushuliang);
                holder.tvLouzhu = (TextView) convertView.findViewById(R.id.luntan_tiezi_louzhu);
                convertView.setTag(holder);
            }else{
                holder = (ViewHolder) convertView.getTag();
            }
            return convertView;
        }
    }

    static class ViewHolder {
        public TextView tvTiezi;
        public TextView tvHuifu;
        public TextView tvLouzhu;
    }

}
